$(function() {
    $('.input_sub').on('click', function() {
        let username = $('.input_txt').val()
        let password = $('.input_pass').val()
            // console.log(username, password);
        $.ajax({
            type: 'post',
            // url: 'http://localhost:8080/api/v1/admin/user/login',
            url: bigNews.user_login,
            data: { username, password },
            dataType: 'json',
            success: function(res) {
                // console.log(res);
                $('.modal-body>p').text(res.msg)
                if (res.code === 200) {
                    //将登录验证成功的token值存储在本地，后面操作需要使用token值进行后台验证
                    localStorage.setItem('bigNews_token', res.token)
                    $('#tipModal').modal('show')
                    $('#tipModal').on('hidden.bs.modal', function(e) {
                        // location.href = './index.html'
                        location.assign('./index.html')
                    })
                } else {
                    $('#tipModal').modal('show')
                }
            }
        })
    })
    $('.btn-confirm').on('click', function() {
        $('#tipModal').modal('hide')
    })

})